package cn.wetcland.urban.framework.controller;

import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.framework.annotation.SaCheckDriverLogin;
import cn.wetcland.urban.framework.dto.DriverAddCarDTO;
import cn.wetcland.urban.framework.service.UtCarService;
import cn.wetcland.urban.framework.vo.CarBrandListItemVO;
import cn.wetcland.urban.framework.vo.CarSerialListItemVO;
import cn.wetcland.urban.framework.vo.DriverCarDetailsVO;
import cn.wetcland.urban.framework.vo.DriverOrderListItemVO;
import cn.wetcland.urban.generator.dto.BaseConditionSearchDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/car")
public class CarController {

    @Resource
    public UtCarService carService;

    @SaCheckDriverLogin
    @GetMapping("/carBrandList")
    public AjaxResponse carBrandList() {
        List<CarBrandListItemVO> carBrandListItemVOS = carService.carBrandList();
        return AjaxResponse.success(carBrandListItemVOS);
    }

    @SaCheckDriverLogin
    @GetMapping("/carSerialList/{parentId}")
    public AjaxResponse carSerialList(@PathVariable Long parentId) {
        List<CarSerialListItemVO> carBrandListItemVOS = carService.carSerialList(parentId);
        return AjaxResponse.success(carBrandListItemVOS);
    }

    @SaCheckDriverLogin
    @PostMapping("/driverAddCar")
    public AjaxResponse driverAddCar(@Validated @RequestBody DriverAddCarDTO addCarDTO) {
        carService.driverAddCar(addCarDTO);
        return AjaxResponse.success();
    }

    @SaCheckDriverLogin
    @GetMapping("/driverCarDetails")
    public AjaxResponse driverCarDetails() {
        DriverCarDetailsVO carDetailsVO = carService.driverCarDetails();
        return AjaxResponse.success(carDetailsVO);
    }

    @SaCheckDriverLogin
    @DeleteMapping("/driverCarDelete")
    public AjaxResponse driverCarDelete() {
        carService.driverCarDelete();
        return AjaxResponse.success();
    }

}
